package com.example.mapper;

import com.example.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select * from user where userID = #{userID}")
    User getByID (Integer userID);


    void deleteByIDs(List<Integer> userIDs);

    @Insert("insert into user(username,phone_number,gender,salt,password,name,id_number,user_type,create_time,update_time)" +
            "values(#{username},#{phoneNumber},#{gender},#{salt},#{password},#{name},#{idNumber},#{userType},#{createTime},#{updateTime})")
    void insert(User user);

    void update(User user);

    List<User> list(String name, Short gender,Short userType, LocalDate begin, LocalDate end);

    @Select("select * from user " +
            "where username=#{username}")
    User getByUsername(User user);

    @Select("select * from user " +
            "where id_number=#{idNumber}")
    User selectUserByIdNumber(String idNumber);

    @Select("select count(userID) from user where username=#{userName}")
    int isExistUserName(String userName);
}
